<?php
/**
 * @link http://www.tintsoft.com/
 * @copyright Copyright (c) 2013 TintSoft LLC
 * @license http://www.tintsoft.com/license/
 */
namespace Leaps\Helper;

/**
 * BaseHtmlPurifier 提供[[HtmlPurifier]]具体的实现
 * 不要使用 BaseHtmlPurifier. 使用 [[HtmlPurifier]]
 *
 * @author Tongle Xu <xutongle@gmail.com>
 * @since 5.0
 */
class BaseHtmlPurifier
{
    /**
     * 将通过HTMLPurifier标记使它安全输出传递给终端用户
     *
     * @param string $content
     * @param array|null $config
     * @return string
     */
    public static function process($content, $config = null)
    {
        $configInstance = \HTMLPurifier_Config::create($config);
        $configInstance->autoFinalize = false;
        $purifier=\HTMLPurifier::instance($configInstance);
        $purifier->config->set('Cache.SerializerPath', \Yii::$app->getRuntimePath());
        return $purifier->purify($content);
    }
}